
package model.xmlconvert;

public class ModelChartFactory{
	
	private static ModelStartFlowChartComponent start = new ModelStartFlowChartComponent();
	private static ModelEndFlowChartComponent end = new ModelEndFlowChartComponent();
	private static int diamondCount = 0;
	private static int rectangleCount = 0;
	private static int rombezCount = 0;
	private static int arrowCount;
	
	static ModelLinkFlowChartComponent createArrowComponent(ModelFlowChartComponent from, ModelFlowChartComponent to){	
		return new ModelLinkFlowChartComponent("arrow" + (arrowCount++), from, to);
	}
	
	static ModelDiamondLinkFlowChartComponent createDiamondArrrowComponent(ModelFlowChartComponent from, ModelFlowChartComponent to,ModelLinkFlowChartComponent.ArrowType type){
		return new ModelDiamondLinkFlowChartComponent("arrow" + (arrowCount++), from, to, type);
	}
	
	public static ModelFlowChartComponent createComponent(String name){
		
		if(name.equals("start")){
			return start;
		}
		
		if(name.equals("end"))
			return end;
		
		if(name.equals("diamond"))
			return new ModelDiamondFlowChartComponent("diamond" + (diamondCount++));
		
		if(name.equals("rombez"))
			return new ModelRombezFlowChartComponent("rombez" + (rombezCount++));
		
		if(name.equals("rectangle"))
			return new ModelRectangleFlowChartComponent("rectangle" + (rectangleCount++));
		
		return null;
	}
}